package com.hqyj.smvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStream;
import java.sql.Array;
import java.util.ArrayList;

@Controller
public class GetIconsController {

    @GetMapping(value = "/getIcon")
    public String getIcon(Model model){
        ArrayList<String> icons = new ArrayList<>();
        try {
            BufferedReader reader = new BufferedReader(new FileReader("E:\\Java\\porject\\maven\\java22031\\Spring_ssm\\EmployeeManagement\\src\\main\\resources\\icons\\icons.txt"));
                // .icon-glass:before {
                String context = "";
                while (( context = reader.readLine()) != null){
                    if (context.startsWith(".")){
                        String[] strings = context.split(":");
                        String temp = strings[0];
                        char[] chars = temp.toCharArray();
                        String text = "";
                        for(int i = 1;i< chars.length; i++){
                            text += chars[i];
                        }
                        icons.add(text);
                    }
                }
            System.out.println(icons);
                model.addAttribute("icons",icons);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "icons";
    }

}
